Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create HATAirdrop #542

Merged
merged 18 commits into from
Feb 29, 2024
Merged

Create HATAirdrop #542

merged 18 commits into from
Feb 29, 2024

Conversation

ben-kaufman
Copy link
Collaborator

No description provided.

Copy link

openzeppelin-code bot commented Nov 22, 2023

Create HATAirdrop

Generated at commit: 652566fa1bedf1ed5f3504cfb8c2e47e39a5a6e9

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
0
0
13
31
46
Dependencies Critical
High
Medium
Low
Note
Total
0
0
2
0
66
68

For more details view the full report in OpenZeppelin Code Inspector

bytes32 public root;
uint256 public startTime;
uint256 public deadline;
uint256 public lockEndTime;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should consider lock length

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here we can either just start from a certain date to a certain date, or we can start on claim and end after X time. I implemented the former but we the latter is also a valid option, we just need to decide what behavior we want here.

Copy link
Collaborator

@jellegerbrandy jellegerbrandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the pattern "redeem -> tokenlock.release()to get your tokens is pretty bad ux: it is hard to understand, and esp for small amounts it is a lot of gas costs. One limit case is where all tokens are already vested on theredeem()` call - in that case it would be much nicer (chepaer, easier) to just get the tokens directly (see my suggestion there).

  • it would be cool to have some way to claim several airdrops in a single tx. Something like factory.redeem(airDropContracts[], proofs[], amounts[], account)

implementation = _implementation;
}

function updateImplementation(address _newImplementation) external onlyOwner {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is nice but it is not as flexible as it looks, bc any implementation contract needs to use the same signature for the initialization function. If we want the flexibility to create new airdrop contracts, we proably should pass the arguments encoded in a single parameter (but also that has it's drawbacks in terms of ux)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok yeah it'd be more flexible

leafRedeemed[leaf] = true;

address _tokenLock = address(0);
if (lockEndTime != 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (lockEndTime != 0) {
if (lockEndTime > block.timestamp) {

uint256 _lockEndTime,
uint256 _periods,
uint256 _totalAmount,
IERC20Upgradeable _token,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to airdrop tokens different than hats? IF not, perhaps this argument should be in the constructor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we might do different tokens or not

emit ImplementationUpdated(_newImplementation);
}

function withdrawTokens(IERC20Upgradeable _token, uint256 _amount) external onlyOwner {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this allows for rugpulling the airdrop, as we discussed, and to mitigate we expect the funtion to be timelocked. Do we want a comment explaining that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If users do not redeem their tokens from the airdrop contract bf the deadline, hats can get those tokens back calling withdrawTokens. However, unclaimed tokens in the tokenlock will be lost forever. This can kind of be grief-attacked by an attacker that calls redeem on all unclaimed leafs just before the deadline (or even frontrunning withdrawTokens)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you'd recommend allowing only beneficiary to redeem for themselves right?

}

function withdrawTokens(IERC20Upgradeable _token, uint256 _amount) external onlyOwner {
address owner = owner();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably save a miniscule amount of gas

Suggested change
address owner = owner();
address owner = msg.sender;

jellegerbrandy
jellegerbrandy previously approved these changes Jan 15, 2024
Copy link
Collaborator

@jellegerbrandy jellegerbrandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just one small update on the docstring

Co-authored-by: Jelle <jellegerbrandy@gmail.com>
Signed-off-by: benk10 <ben.kaufman10@gmail.com>
@jellegerbrandy jellegerbrandy merged commit 58f4c83 into develop Feb 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants